package com.mxpio.erp.technology.policy.impl;

import com.mxpio.erp.common.technology.entity.*;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.jpa.policy.CrudContext;
import com.mxpioframework.jpa.policy.impl.SmartCrudPolicyAdapter;
import org.springframework.stereotype.Component;

@Component
public class ItemUpdatePolicy extends SmartCrudPolicyAdapter {
    @Override
    public void afterUpdate(CrudContext context) {//级联更新bominfoline
        Object o = context.getEntity();
        if(o instanceof Item){
            Item item = (Item) o;
            JpaUtil.linu(BomInfoLine.class)
                    .set("itemName",item.getItemName())
                    .set("itemSpec",item.getItemSpec())
                    .set("itemSource",item.getItemSource())
                    .set("material",item.getMaterial())
                    .set("materialBrand",item.getMaterialBrand())
                    //.set("virtualPart",item.getVirtualPart())
                    .equal("itemCode",item.getItemCode())
                    .update();
        }
    }
}
